<%--
  Created by IntelliJ IDEA.
  User: 86186
  Date: 2025/6/30
  Time: 09:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
        <title>实现文件上传</title>
        <script type="application/javascript" src="${pageContext.request.contextPath}/js/jquery-3.6.0.js"></script>
        <script type="application/javascript">
            $(function(){
                $("#upBtn").click(function(){
                   if($("#file").value==""){
                       alert("请选择文件！")
                   } else {
                       $("#form").submit();
                   }
                });
            })
        </script>
        <style>
            #uploadDiv{
                padding: 30px;
                line-height: 30px;
            }
            
            #file{
                height: 30px;
                width: 260px;
                outline: none;
            }
            
            #upBtn{
                height: 30px;
                width: 80px;
                border: 1px solid cornflowerblue;
                background-color: cornflowerblue;
            }
        </style>


    </head>
    <body>
        <div id="uploadDiv">
            <form method="post" id="form" enctype="multipart/form-data"
                  action="${pageContext.request.contextPath}/save_upload.action">
                <span>实现文件上传：</span>
                <input type="file" id="file" name="file" ><br>
                <input type="button" value="上传文件" id="upBtn" />
            </form>
        </div>

        <br/>
        <h3></h3>
        <table border="1" width="500px">
            <tr>
                <th width="80px">序号</th>
                <th width="120px">文件名</th>
                <th>下载文件</th>
            </tr>
            <c:forEach var="file" varStatus="status" items="${filelist}">
                <tr>
                    <td>${status.count}</td>
                    <td>${file.name}</td>
                    <td><a href="${pageContext.request.contextPath}${file.path}">下载</a></td>
                </tr>
            </c:forEach>
        </table>

    </body>
</html>
